package com.jun.basic.controller;

import com.jun.basic.config.WxConfig;
import com.jun.basic.task.AsyncTask;
import com.jun.basic.utils.JsonData;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/api/v1/test")
public class TestController {
    @Resource
    private WxConfig wxConfig;
    @Resource
    private AsyncTask asyncTask;

    @GetMapping("/get/config")
    public JsonData<Map<String, String>> getConfig(){
        Map<String, String> configMap = new HashMap<>();
        configMap.put("payId", wxConfig.getPayId());
        configMap.put("paySecret", wxConfig.getPaySecret());
        configMap.put("payMechid", wxConfig.getPayMechId());

        return JsonData.buildSuccess(configMap);
    }

    @GetMapping("/async")
    public JsonData<String> async(){
        asyncTask.print1();
        asyncTask.print2();
        log.info("AsyncTask print");
        return JsonData.buildSuccess("");
    }
}
